package com.yenlien.traceyun.usercenter.dao;

import com.yenlien.traceyun.usercenter.entity.Department;
import com.yenlien.traceyun.webase.dao.BaseJpaDao;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Set;

/**
 * Created by LiuSha on 2020/6/9.
 */
public interface DepartmentDao extends BaseJpaDao<Department> {
    Department findById(String id);

    List<Department> findByCompanyId(String companyId);

    List<Department> findByParentId(String parentId);

    Department findByName(String name);

    Department findByNameAndCompanyId(String name, String companyId);

    Department findByNameAndParentId(String name, String parentId);

    @Query(value = "select * from ssqy_department where `name` =?1 AND (parent_id ='' OR  parent_id is NULL)", nativeQuery = true)
    Department findByParentName(String name);

    @Query(value = "select d.name from Department d where d.id=?1")
    String getByName(String id);

}
